<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数参数的解构析值</title>
  </head>

  <body>

  </body>
  <script>
    /* 
    函数参数的解构析值
    */
    //1.参数值是一组有秩序的值
    function f([x, y, z]) {
      console.log(x, y, z);
    }
    f([1, 2, 3]); //1 2 3

    //2.参数是一组无秩序的值
    function func({
      x,
      y,
      z
    }) {
      console.log(x, y, z);
    }
    func({
      z: 60,
      y: 30,
      x: 10
    }); //10 30 60


    //3.对象这种写法默认不传的话，会报错:设置默认值
    function fn({
      a,
      b
    } = {}) {
      console.log(a, b);
    }
    fn() //undefined undefined

    //4.解构默认值和参数默认值的综合使用
    function fnc({
      a = "jason",
      b = 18
    } = {}) {
      console.log(a, b);
    }
    fnc() //jason 18
  </script>

</html>